package com.xiaoniu.lib_keleim.utils;

import com.xiaoniu.lib_keleim.IMClient;
import com.xiaoniu.lib_keleim.TextMessageUtils;
import com.xiaoniu.lib_keleim.db.manager.MessageDao;
import com.xiaoniu.lib_keleim.pojo.vos.BaseMessage;
import com.xiaoniu.lib_keleim.pojo.vos.UserInfoVO;

public class MessageUtils {

    public static BaseMessage sendTextMessage(long target, String content) {
        return sendTextMessage( target,  content, null);
    }

    public static BaseMessage sendTextMessage(long target, String content, String ext) {
        BaseMessage textMessage = TextMessageUtils.Companion.getP2PTextMessage(target,content);
        textMessage.ext = ext;
        IMClient.Companion.getManager().sendMessage(textMessage);
        MessageDao.getInstance().updateMessageEntity(textMessage);
        MessageDao.getInstance().updateConversationEntity(textMessage.toConversationVO(target));
        return textMessage.toMessageChatVO();
    }



    public static void setBaseInfo(BaseMessage textMessage) {
        textMessage.platformIdentity = 1;
        textMessage.messageId = System.currentTimeMillis();
        textMessage.timestamp = System.currentTimeMillis();
        textMessage.sendUser = TextMessageUtils.Companion.getSendUser();
        textMessage.userId = UserInfoVO.getSingleton().customerId;
    }

}
